<?php

namespace App\Http\Controllers\Store;

use App\Http\Controllers\Controller;
use App\Model\Group_member;
use App\Model\Store;
use App\Model\Users;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class CommonController extends Controller
{
    protected $company_id;
	protected $store_id;
	protected $store_name;
	protected $Group_member;
	public function __construct()
	{
		$userData=Auth::user();
		$storeData=Store::where(['leader_id'=>$userData['id']])->first();
		$this->company_id=Users::where(['id'=>$userData['id']])->first()->company_id;
		$this->store_id=$storeData->id;
		$this->store_name=$storeData->store_name;
		$this->Group_member=new Group_member();
	}

	public function response($code,$data){
		if($code==200){
			return ['code'=>$code,'message'=>'操作成功','data'=>$data];
		}
		if($code==400){
			return ['code'=>$code,'message'=>'操作失败','data'=>''];
		}
	}

	//	查询用户归属用户组
	public function belongsToGroup($department_id){
		$data=$this->Group_member->where(['department_id'=>$department_id])->first();
		$group_id=$data->group_id;
		return $group_id;
	}

}
